package neusoft.yuejian_11.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.squareup.picasso.Picasso;

import java.util.List;

import neusoft.yuejian_11.base.BaseListAdapter;
import neusoft.yuejian_11.bean.CourseBean;
import neusoft.yuejian_11.R;
import neusoft.yuejian_11.viewHolder.CourseitemViewHolder;

import static neusoft.yuejian_11.interF.Const.BASE_URI;

/**
 * Created by neusoft on 2017/10/12.
 */

public class CourseListAdapter extends BaseListAdapter {
    public CourseListAdapter(Context context, List data) {
        super(context, data);
    }

    @Override
    protected RecyclerView.ViewHolder onCreateVH(ViewGroup parent, LayoutInflater layoutInflater, int viewType) {
        View itemView = layoutInflater.inflate(R.layout.item_course_list, parent, false);
        CourseitemViewHolder viewHolder = new CourseitemViewHolder(itemView);
        return viewHolder;
    }

    @Override
    protected void onBindVH(RecyclerView.ViewHolder holder, List data, int position) {
        CourseBean course = (CourseBean) data.get(position);
        CourseitemViewHolder viewHolder = (CourseitemViewHolder) holder;

        final int clubId = course.getC_id();
        String courseTime = course.getCc_time();
        int courseLevel = course.getCc_level();
        String courseName = course.getCc_name();
        String coursePrice = course.getCc_price();

        viewHolder.courseTimeView.setText(courseTime);
        viewHolder.courseLevelView.setText(String.valueOf(courseLevel));
        viewHolder.courseNameView.setText(courseName);
        viewHolder.coursePriceView.setText(coursePrice);

        String coursePic = BASE_URI+"coursephoto/"+course.getCc_pic();
        Picasso.with(context)
                .load(coursePic)
                .placeholder(R.drawable.ic_club)
                .error(R.drawable.ic_noclub)
                .into(viewHolder.imageView);

    }
}
